Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Upgrade [email protected] and [email protected] #360

Closed
wants to merge 23 commits into from

Conversation

AdamMagaluk
Copy link
Collaborator

Will hopefully address #336 and #333 also will help to modernize the codebase as it will support all the latest versions of node see: #337.

This PR has the basics working though there are a number of broken tests. Peering works. Websockets and data between peers all working tested with the trusty zetta browser.

The biggest roadblock right now is the spdy lib no longer supports a way of intercepting or sending spdy pings. Few options:

  • Fork and get a PR accepted in spdy that supports our use case.
  • Fork and use a vendored version of spdy that will support our use case.
  • Don't use spdy pings for keep alive messages but some other specific http endpoint.

Tested against with (simple example not unit/integration tests):

  • v6.9.1
  • v8.6.0
  • v9.1.0

Breaks with v0.12 and v0.10 because of the ws module use of const.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If your company signed a CLA, they designated a Point of Contact who decides which employees are authorized to participate. You may need to contact the Point of Contact for your company and ask to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot.
  • In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@AdamMagaluk AdamMagaluk mentioned this pull request Nov 30, 2017
@AdamMagaluk
Copy link
Collaborator Author

@kevinswiber Thoughts on what support for v0.10 and v0.12 should be. The ws@3x dependency won't support < v4 per websockets/ws#1077 i'm leaning towards EOL v0.10 and v0.12 for Zetta too since Node is.

If people still need it they can use the current version of Zetta. Interesting to check what version of BBB are shipped with now.

@kevinswiber
Copy link
Member

@AdamMagaluk Yes, I think it's time to say good-bye to v0.10 and v0.12. Choosing where to shift our compatibility promise is another issue. How well does Node 8 work on a Beagleboard? What do the latest boards ship with by default? Those are questions that might be important to answer.

@kevinswiber
Copy link
Member

A change to the keepalive mechanism will be a change to the Z2Z protocol. Could we do it in a way that doesn't break compatibility?

Z2Z is in need of a big overhaul. What we know today about HTTP/2 is so much more than what we knew then about SPDY/3. I'd make a few major changes, for sure. So if we need to break compatibility, how far do we go?

@AdamMagaluk
Copy link
Collaborator Author

Yeah we "can" do it without breaking changings will just need to make some modifications to the spdy library, no options to monkey patch it either right now.

Agreed but for the scope of "just get zetta up-to-date current node" I think that probably deserves a separate discussion.

I reached out to our friend Jason and Beaglebone to ask about the Node version.

@AdamMagaluk
Copy link
Collaborator Author

Update:

Pings working again using a forked version of node-spdy with a small change. Ideally we land that in the actual node-sody but we'll see.

Found another issue while working on fixing the integration tests. For some reason when running two zetta servers within the same Node.js process the peering fails with socket hang up..

full.js

var zetta = require('../');
var MemoryRegistries = require('zetta-memory-registry')(zetta);

var PeerRegistry = MemoryRegistries.PeerRegistry;
var DeviceRegistry = MemoryRegistries.DeviceRegistry;


cloud = zetta({ registry: new DeviceRegistry(), peerRegistry: new PeerRegistry() });
cloud.name('A');
cloud.listen(0, function(err) {
  if (err) {
    throw err;
  }

  var cloudUrl = 'ws://localhost:' + cloud.httpServer.server.address().port;

setTimeout(function() {
  z = zetta({ registry: new DeviceRegistry(), peerRegistry: new PeerRegistry() })
    .name('B')
    .link(cloudUrl)
    .listen(0);
  }, 1000)
})
λ: node full.js
Dec-03-2017 15:33:55 [server] Server (A) A listening on http://127.0.0.1:0
Dec-03-2017 15:33:56 [server] Server (B) B listening on http://127.0.0.1:0
Dec-03-2017 15:33:56 [http_server] Websocket connection for peer "B" established.
Dec-03-2017 15:33:56 [peer-client] WebSocket to peer established (ws://localhost:63566/peers/B)
Dec-03-2017 15:33:56 [peer-client] Peer connection closed (ws://localhost:63566/peers/B): undefined - undefined
Dec-03-2017 15:33:56 [http_server] Peer connection closed for "B".
Dec-03-2017 15:33:56 [http_server] Peer connection failed for "B": socket hang up.

Dec-03-2017 15:33:57 [http_server] Websocket connection for peer "B" established.
Dec-03-2017 15:33:57 [peer-client] WebSocket to peer established (ws://localhost:63566/peers/B)
Dec-03-2017 15:33:57 [peer-client] Peer connection closed (ws://localhost:63566/peers/B): undefined - undefined
Dec-03-2017 15:33:57 [http_server] Peer connection closed for "B".
Dec-03-2017 15:33:57 [http_server] Peer connection failed for "B": socket hang up.

@googlebot
Copy link

CLAs look good, thanks!

@AdamMagaluk
Copy link
Collaborator Author

More progress... but issue above was fixed. Now working through the test suite and fixing mainly minor issues. Next major one is around the multiplexed event stream not working in some cases.

λ: npm test

> [email protected] test /Users/adammagaluk/Software/zetta/zetta
> mocha -R spec

(node:21585) DeprecationWarning: child_process: options.customFds option is deprecated. Use options.stdio instead.


  Zetta Api
    ✓ updates href hosts using x-forwarded-host header (67ms)
    ✓ updates href path using x-forwarded-path header
    ✓ allow for x-forwarded-host header to be disabled
    ✓ allow for x-forwarded-path header to be disabled
    /servers/<peer id>
      ✓ should have content type application/vnd.siren+json
      ✓ should return status code 200
      ✓ should have class ["server"]
      ✓ should have proper name and id property
      ✓ should have custom properties in resp
      ✓ should have self link and log link
      ✓ should have a metadata link
      ✓ should have monitor log link formatted correctly for HTTP requests
      ✓ should have monitor log link formatted correctly for SPDY requests (38ms)
      ✓ should not have an events link for SPDY requests
      ✓ should have valid entities
      ✓ should have one action
      ✓ should accept remote devices of type testdriver
      ✓ should not accept a remote device of type foo
      ✓ should accept remote devices of type testdriver, and allow them to set their own id properties
      ✓ query for device should respond with properly formated api response
    /
      ✓ should have content type application/vnd.siren+json
      ✓ should have status code 200
      ✓ body should contain class ["root"]
      ✓ body should contain links property
      ✓ links should contain rel to server
      ✓ should contain link for event stream
      ✓ should use a default server name if none has been provided
    /peer-management
      ✓ should have content type application/vnd.siren+json
      ✓ should return status code 200
      ✓ should have class ["peer-management"]
      ✓ subentities should have rel ["item"]
      ✓ should list saved peers
      ✓ should allow the querying of peers with the ql parameter
      #link
        ✓ should return status code 202
        ✓ should return a Location header
        ✓ should return Location header whose value honors forwarded host
        ✓ should return Location header whose value honors forwarded path
      #show
        ✓ should return the peer item representation
    /devices of server
      ✓ should have content type application/vnd.siren+json
      ✓ should return status code 200
      ✓ should have class ["devices"]
      ✓ should have one valid entity
      ✓ should replace url host in all device links using forwarded host
      ✓ should inject path in all device links using forwared root path
    /servers/:id/devices/:id
      ✓ should have content type application/vnd.siren+json
      ✓ class should be ["device", ":type"]
      ✓ properties should match expected
      ✓ device should have action change
      ✓ device actions should have class "transition"
      ✓ device should have self link
      ✓ device should have edit link
      ✓ device should have up link to server
      ✓ device should have monitor link for bar
      ✓ disabling a stream should remove it from the API.
      ✓ enabling a stream should show it in the API.
      ✓ device should have monitor link for bar formatted correctly for HTTP requests
      ✓ should have a monitor link for bar formatted correctly for SPDY requests
      ✓ device action should return a 400 status code on a missing request body
      ✓ device action should return a 400 status code on an invalid request body
      ✓ device action should work
      ✓ device action should support extended characters
      ✓ api should decode transition args to number for test-number
      ✓ api should decode transition args to string for test-text
      ✓ api should decode transition args to string for test-none
      ✓ api should decode transition args to object for test-date
      ✓ api should respond with 400 when argument is not expected number
      ✓ api should respond with 400 when argument is not expected Date
      ✓ device action should return 400 when not available.
      ✓ should return 500 when a error is passed in a callback of device driver
      ✓ should return custom error information when a error is passed in a callback of device driver
      ✓ should support device updates using PUT
      ✓ should support device deletes using DELETE
      ✓ remoteDestroy hook should prevent the device from being destroyed with a DELETE
      ✓ remoteDestroy hook should prevent the device from being destroyed with a DELETE if callback has an error
      ✓ remoteDestroy hook should allow the device to be destroyed when callback is called with true
      ✓ should not overwrite monitor properties using PUT
      ✓ should return a 404 when updating a non-existent device
      ✓ should return a 400 when updating with a Content-Range header
      ✓ should return a 400 when receiving invalid JSON input
      ✓ should not include reserved fields on device updates
    Proxied requests
      ✓ zetta should not crash when req to hub is pending and hub disconnects
      ✓ zetta should return 404 on non-existent peer
      ✓ zetta should return 404 on disconnected peer
      ✓ device action should support extended characters throw a proxied connection
    Server name issues
      ✓ server name with space has correct path to root of server
      ✓ server name with space has correct path to device

  Registry Compaction
    custom database
      ✓ should not have a compactor property with a custom db.
    standard medea database
      ✓ should have a compactor property without a custom db.
      ✓ should call open before compact.
      ✓ should call compact.
      ✓ should call close.

  ConsumerStream
    ✓ it should subscribe to pubsub topic
    ✓ it pass pubsub data to stream

  Driver
    ✓ should be attached to the zetta runtime
    ✓ should expose an enableStream function
    ✓ should expose a disableStream function
    Configuration
      ✓ should be configured by Scientist#configure
      ✓ should have an id automatically generated for it
      ✓ should have properties function
      ✓ properties function should return filtered property list
    Logging
      ✓ should expose a .log method
      ✓ should have log level functions
    Transitions
      ✓ should not throw when calling an invalid transition name.
      ✓ should not throw when calling a transition when destroyed.
      ✓ should not throw when calling a transition not allowed in invalid state.
      ✓ avialable transitions should not throw when in invalid state.
      ✓ should change the state from ready to changed when calling change.
      ✓ should be able to call transiton afterchange after change was called
      ✓ should not throw an error when a disallowed transition tries to happen.
      ✓ should return error in callback.
      ✓ should have transitions emitted like events.
      ✓ should publish transitions to pubsub
      ✓ should publish transitions to logs
      ✓ transitionsAvailable should return proper transitions
    Monitors
      ✓ should be able to read state property
      ✓ should be able to read monitors properties
      ✓ should be able to pass disable option to monitor
    Streams
      ✓ should stream values of foo once configured
      ✓ should be able to pass disable option to stream
      ✓ should have createReadSteam on device
      ✓ createReadStream should return values from stream
      ✓ createReadStream stream when paused shoud not recieve any updates
      ✓ should stream values of bar once configured
      ✓ should create a state stream when transitions are present
      ✓ should not create a state stream when no transitions are present
    Device.save
      ✓ save should be implemented on device
      ✓ save should update the registry with new property values
    Remote Update and Fetch Hooks
      ✓ can pass config a remoteFetch function to be called when .properties() is called
      ✓ handle remote update method, will update non reserved properties and remove old properties
      ✓ can pass config a remoteUpdate function to be called when remoteUpdates are called
    Deletion
      ✓ should have a destroy function
      ✓ should emit a destroy event when destroy is called.
      ✓ handle remote destroy method, will return true by default

  EventBroker
    ✓ it should add peer by server name
    ✓ it should pass data from local pubsub to clients
    ✓ should keep local pubsub subscription open when more than one client is active

  EventSocket
    ✓ it should initialization with topic set
    ✓ EventSocket.send should pass data/options/callback to ws send
ws error: Error: some error
    at Context.<anonymous> (/Users/adammagaluk/Software/zetta/zetta/test/test_event_socket.js:48:22)
    at Test.Runnable.run (/Users/adammagaluk/Software/zetta/zetta/node_modules/mocha/lib/runnable.js:217:15)
    at Runner.runTest (/Users/adammagaluk/Software/zetta/zetta/node_modules/mocha/lib/runner.js:373:10)
    at /Users/adammagaluk/Software/zetta/zetta/node_modules/mocha/lib/runner.js:451:12
    at next (/Users/adammagaluk/Software/zetta/zetta/node_modules/mocha/lib/runner.js:298:14)
    at /Users/adammagaluk/Software/zetta/zetta/node_modules/mocha/lib/runner.js:308:7
    at next (/Users/adammagaluk/Software/zetta/zetta/node_modules/mocha/lib/runner.js:246:23)
    at Immediate.<anonymous> (/Users/adammagaluk/Software/zetta/zetta/node_modules/mocha/lib/runner.js:275:5)
    at runCallback (timers.js:637:20)
    at tryOnImmediate (timers.js:610:5)
    at processImmediate [as _immediateCallback] (timers.js:582:5)
    ✓ websocket error event should trigger close on EventSocket
    ✓ websocket close event should trigger close on EventSocket
    ✓ should init parser if passed streaming flag
    ✓ should pass filterMultiple flag to EventSocket
    ✓ should emit subscribe event when subscribe message is parsed
    ✓ should not fail when sending null object with streamEnabled=true
    ✓ should not fail when sending null object with streamEnabled=false

  Event Stream Parser
    ✓ validates subscribe messages correctly
    ✓ invalidates subscribe messages correctly
    ✓ validates unsubscribe messages correctly
    ✓ invalidates unsubscribe messages correctly
    ✓ validates unsubscribe-ack messages correctly
    ✓ invalidates unsubscribe-ack messages correctly no subscriptionId
    ✓ invalidates unsubscribe-ack messages correctly no timestamp no subscriptionId
    ✓ invalidates unsubscribe-ack messages correctly no timestamp
    ✓ validates subscribe-ack messages correctly
    ✓ validates error messages correctly
    ✓ validates event messages correctly
    ✓ should emit event for message type when parsing buffer
    ✓ should emit error for invalid message type when parsing buffer
    ✓ should emit error for invalid JSON when parsing buffer

  Peering Event Streams
    ✓ will receive a _peer/connect event when subscribed
    ✓ will receive a _peer/connect event when subscribed to **
    ✓ will receive a _peer/disconnect event when subscribed
    ✓ will receive a _peer/connect event when subscribed with wildcards
    ✓ will receive a _peer/connect and _peer/disconnect event when subscribed with wildcards

  Event Streams
    Websocket API
      ✓ for cloud, subscribing to a topic receives a subscription-ack
      ✓ for hub, subscribing to a topic receives a subscription-ack
      ✓ for cloud, sending ping request will return a pong response without data field
      ✓ for hub, sending ping request will return a pong response without data field
      ✓ for cloud, sending ping request will return a pong response with data field
      ✓ for hub, sending ping request will return a pong response with data field
      ✓ for cloud, unsubscribing to a topic receives a unsubscription-ack
      ✓ for hub, unsubscribing to a topic receives a unsubscription-ack
      ✓ for cloud, verify error message format
      ✓ for hub, verify error message format
      ✓ for cloud, specific topic subscription only receives messages with that topic (68ms)
      ✓ for hub, specific topic subscription only receives messages with that topic (59ms)
      ✓ for cloud, multiple clients specific topic subscription only receives messages with that topic (63ms)
      ✓ for hub, multiple clients specific topic subscription only receives messages with that topic (55ms)
      ✓ for cloud, multiple clients using different topic subscriptions only receive one message per event (253ms)
      ✓ for hub, multiple clients using different topic subscriptions only receive one message per event (254ms)
      ✓ for cloud, wildcard server topic subscription only receives messages with that topic (57ms)
      ✓ for hub, wildcard server topic subscription only receives messages with that topic (56ms)
      ✓ for cloud, wildcard topic and static topic subscription will receive messages for both subscriptions (59ms)
      ✓ for hub, wildcard topic and static topic subscription will receive messages for both subscriptions (54ms)
{"type":"subscribe-ack","timestamp":1519074933579,"topic":"hub/testdriver/*/state","subscriptionId":1}
go...
      1) for cloud, wildcard device id topic subscription and cloud app query both will recieve data
{"type":"subscribe-ack","timestamp":1519074935595,"topic":"hub/testdriver/*/state","subscriptionId":1}
go...
{"type":"event","topic":"hub/testdriver/3a955e03-e25a-4a1b-b214-bbfb1169e5f3/state","timestamp":1519074935646,"subscriptionId":1,"data":"changed"}
      ✓ for hub, wildcard device id topic subscription and cloud app query both will recieve data (65ms)
      ✓ for cloud, wildcard device id topic subscription and hub app query both will recieve data (84ms)
      ✓ for hub, wildcard device id topic subscription and hub app query both will recieve data (56ms)
      ✓ wildcard server topic subscription receives messages from both hubs (58ms)
      2) wildcard topic ** will subscribe to all topics for both hubs
      ✓ wildcard topic ** will subscribe to all topics for single hub (56ms)
      ✓ for cloud, wildcard topic for single peer receives all messages for all topics (59ms)
      ✓ for hub, wildcard topic for single peer receives all messages for all topics (58ms)
      3) for cloud, wildcard topic for device id and stream types receives all messages for all topics
      ✓ for hub, wildcard topic for device id and stream types receives all messages for all topics (58ms)
      ✓ for cloud, **/led/<device_id>/state will match valid topic (61ms)
      ✓ for hub, **/led/<device_id>/state will match valid topic (59ms)
      ✓ for cloud, **/<device_id>/state will match valid topic from device (62ms)
      ✓ for hub, **/<device_id>/state will match valid topic from device (58ms)
      ✓ for cloud, **/state will match valid topic from device (56ms)
      ✓ for hub, **/state will match valid topic from device (56ms)
      ✓ for cloud, subscribing to logs topic on device will get properly formated response (60ms)
      ✓ for hub, subscribing to logs topic on device will get properly formated response (56ms)
      ✓ for cloud, topic that doesnt exist still opens stream
      ✓ for hub, topic that doesnt exist still opens stream
      ✓ subscription cloud will get _peer/connect events from hub
      ✓ for cloud, subscription to non existent hub does not return data for that subscriptionId (58ms)
      ✓ for hub, subscription to non existent hub does not return data for that subscriptionId (59ms)
      ✓ for cloud, wildcard and specific topic will each publish a message on a subscription (77ms)
      ✓ for hub, wildcard and specific topic will each publish a message on a subscription (67ms)
      ✓ for cloud, adding limit to subscription should limit number of messages received (264ms)
      ✓ for hub, adding limit to subscription should limit number of messages received (266ms)
      ✓ for cloud, when limit is reached a unsubscribe-ack should be received (66ms)
      ✓ for hub, when limit is reached a unsubscribe-ack should be received (55ms)
      ✓ for cloud, when limit is reached with a query selector a unsubscribe-ack should be received (94ms)
      ✓ for hub, when limit is reached with a query selector a unsubscribe-ack should be received (54ms)
      ✓ for cloud, query field selector should only return properties in selection (59ms)
      ✓ for hub, query field selector should only return properties in selection (53ms)
      ✓ for cloud, query field selector * should all properties in selection (60ms)
      ✓ for hub, query field selector * should all properties in selection (57ms)
      ✓ for cloud, query field selector should return only selected properties (64ms)
      ✓ for hub, query field selector should return only selected properties (57ms)
      ✓ for cloud, subscribing to all ** and then unsubscribing followed by a peer connecting wont crash zetta (422ms)
      ✓ for hub, subscribing to all ** and then unsubscribing followed by a peer connecting wont crash zetta (412ms)
      ✓ for cloud, Passing filterMultiple options to ws only one data event will be sent (69ms)
      ✓ for hub, Passing filterMultiple options to ws only one data event will be sent (57ms)
      ✓ for cloud, Passing filterMultiple options to ws will apply limits for both topics (87ms)
      ✓ for hub, Passing filterMultiple options to ws will apply limits for both topics (56ms)
      ✓ for cloud, Passing filterMultiple options to ws will have no effect on topics with caql query (64ms)
      ✓ for hub, Passing filterMultiple options to ws will have no effect on topics with caql query (55ms)
      ✓ for cloud, subscribing to a query with hub for hub will return all devices
      ✓ for hub, subscribing to a query with hub for hub will return all devices
      ✓ for cloud, subscribing to a query with * for hub will return all devices
      ✓ for hub, subscribing to a query with * for hub will return all devices
      ✓ for cloud, when data is 0 value it should be formatted correctly (55ms)
      ✓ for hub, when data is 0 value it should be formatted correctly (55ms)
      Protocol Errors
        ✓ for cloud, invalid stream topic "*" should result in a 400 error
        ✓ for hub, invalid stream topic "*" should result in a 400 error
        ✓ for cloud, invalid stream topic "hub" should result in a 400 error
        ✓ for hub, invalid stream topic "hub" should result in a 400 error
        ✓ for cloud, invalid stream topic "{hub.+}" should result in a 400 error
        ✓ for hub, invalid stream topic "{hub.+}" should result in a 400 error
        ✓ for cloud, invalid stream topic "*/" should result in a 400 error
        ✓ for hub, invalid stream topic "*/" should result in a 400 error
        ✓ for cloud, invalid stream topic "**/" should result in a 400 error
        ✓ for hub, invalid stream topic "**/" should result in a 400 error
        ✓ for cloud, invalid stream topic "hub/" should result in a 400 error
        ✓ for hub, invalid stream topic "hub/" should result in a 400 error
        ✓ for cloud, invalid stream topic "{hub.+}/" should result in a 400 error
        ✓ for hub, invalid stream topic "{hub.+}/" should result in a 400 error
        ✓ for cloud, invalid stream query should result in a 400 error
        ✓ for hub, invalid stream query should result in a 400 error
        ✓ for cloud, invalid subscribe should result in a 400 error
        ✓ for hub, invalid subscribe should result in a 400 error
        ✓ for cloud, unsubscribing from an invalid subscriptionId should result in a 405 error
        ✓ for hub, unsubscribing from an invalid subscriptionId should result in a 405 error
        ✓ for cloud, invalid type should result in a 405 error
        ✓ for hub, invalid type should result in a 405 error
        ✓ for cloud, unsubscribing from a missing subscriptionId should result in a 400 error
        ✓ for hub, unsubscribing from a missing subscriptionId should result in a 400 error
        ✓ for cloud, on invalid message should result in a 400 error
        ✓ for hub, on invalid message should result in a 400 error

  Event Websocket
    Basic Connection
      ✓ http resource should exist with statusCode 200
      ✓ websocket should connect
      ✓ will return a 404 on non ws urls
      - will return a 404 on non ws urls for /events123123
    Embedding a websocket server
      ✓ can connect to the custom server
      ✓ will fire the connection event on the server
      ✓ can send data down the server websocket
      ✓ can send data up the server websocket
      - will return a 404 on non ws urls
    Receive json messages
      ✓ websocket should recv only one set of messages when reconnecting
      ✓ websocket should connect and recv data in json form
      ✓ websocket should connect and recv device log events from property API updates
      ✓ websocket should connect and recv device log events
      ✓ websocket should recv connect and disconnect message for /peer-management
    Receive binary messages
      ✓ websocket should connect and recv data in binary form

  Event Websocket Proxied Through Peer
    Basic Connection
      ✓ http resource should exist with statusCode 200
      ✓ websocket should connect
    Receive json messages
      ✓ websocket should connect and recv data in json form (107ms)
      ✓ websocket should recv only one set of messages when reconnecting (613ms)
      ✓ websocket should connect and recv device log events (108ms)
    Receive binary messages
      ✓ websocket should connect and recv data in binary form (108ms)

  Metadata API
    ✓ should contain a metadata class
    ✓ should contain a self link
    ✓ should contain a server link
    ✓ should contain a monitor link
    Type Sub-entity
      ✓ should contain a type class
      ✓ should contain properties
      ✓ should contain streams
      ✓ should contain transitions
      ✓ should contain a self link
    Type Sub-resource
      ✓ should contain a type class
      ✓ should contain properties
      ✓ should contain streams
      ✓ should contain transitions
      ✓ should contain a self link
      ✓ should contain a collection link
      ✓ should contain an instances link

  Peer Client
    ✓ should emit error when underlying ws does
    ✓ should emit closed when underlying ws does
    url parsing
      ✓ should calculate the proper url with a trailing slash
      ✓ should calculate the proper url without a trailing slash

  Peer Connection Logic
    #link
      ✓ should work before .listen is ran
      ✓ should work after .listen is ran
      ✓ should wire up request extensions
      ✓ should wire up response extensions
    Handle spdy agent errors
      - should catch error event
    Peer_socket error events
      ✓ http-server should handle multiple error events
      ✓ http-server should handle multiple end events
    Handle timings with ws connects vs actual peer connects
      ✓ peer connects should be the same peer object on the cloud
      4) peer connects should be the same peer object on the cloud with reconnect
      5) peer connects should be the same peer object on the cloud with reconnect with timing issue

  Peer Connection API
    /peer-management embedded entities
      ✓ exposes 2 actions on the embedded entity when connected and initiator
      ✓ exposes 2 actions on the embedded entity when disconnected and initiator
      ✓ exposes 2 actions on the embedded entity when connected and acceptor
      ✓ exposes 0 actions on the embedded entity when disconnected and acceptor
      ✓ when initiator exposes 2 actions on the full entity when connected
      ✓ when initiator exposes 2 actions on the full entity when disconnected
      ✓ when acceptor exposes 2 actions on the full entity when connected
      ✓ when acceptor exposes 0 actions on the full entity when disconnected
    Root API for peers
      ✓ will have rel of server on peer
    /peer-management disconnection API
      ✓ will return 404 if connection does not exist
      ✓ will proxy a disconnection between two peers
      ✓ will disconnect two peers (47ms)
    /peer-management update API
      ✓ will return 404 if connection does not exist
      ✓ will proxy a connection update between two peers (797ms)
      ✓ will update a connection between two peers (498ms)

  Peer Connection Events in Pubsub
    Initiator Events
      ✓ should recieve a _peer/connect event
    Acceptor Events
      ✓ should recieve a _peer/connect event (43ms)

  Peer Registry
    ✓ should save a peer
    ✓ should remove error property on peer save when status is not failed
    ✓ should find multiple peers
    ✓ should get peers by id
    ✓ should delete peers
    ✓ should close
    #add
      ✓ should save new peers
      ✓ should generate an ID for new peers
      ✓ should update existing peers
      ✓ propagates errors from #find
      ✓ propagates errors from #save
      ✓ it should not match entries when both .url are undefined or null
null
      ✓ should get a peer added with an ID greater than Number.MAX_VALUE

  Peer Client Websocket
    ✓ it should connect to ws:// server
    ✓ it should connect to wss:// server (62ms)

  Pubsub Service
    ✓ exposes subscribe / publish
    ✓ subscribe takes a callback and topic
    ✓ subscribe takes a spdy response object
    ✓ publish does not fail when there are no listeners
    ✓ publish passes to callback
PubSub._onResponse encoding not set.
    ✓ publish passes to response
PubSub._onResponse encoding not set.
    ✓ publish passes to response and callback on same topic
    ✓ unsubscribe should remove listener
PubSub._onResponse encoding not set.
    ✓ one http subscription and one callback that match the same event will emit one event on both
    ✓ two subscriptions with callback that match the same event will emit one event on both
PubSub._onResponse encoding not set.
    ✓ two http subscriptions that match the same event will only emit event on the first subscription

  Query
    Constructor
      ✓ implements the .match() prototype.
    match()
      ✓ matches on matching parameters
      ✓ will not matching on non-matching parameters
      ✓ will match everything when an asterisk is the only parameter provided.

  Zetta Query Api
    invalid query
      ✓ returns an error on /
      ✓ returns an error on / when querying across servers
      ✓ returns an error on /servers/<id>
    queries on / with just a ql parameter
      ✓ should have two classes
      ✓ should have two properties: server name and ql
      ✓ should have one action.
      ✓ should have a websocket link to monitor the query.
    queries on / with a ql parameter and a server parameter
      ✓ should have two classes
      ✓ should have two properties: server name and ql
      ✓ should have no actions.
      ✓ should have a websocket link to monitor the query.
    queries on / with a ql parameter and a server parameter that is proxied to
      ✓ should have two classes
      ✓ should have two properties: server name and ql
      ✓ should have no actions.
      ✓ should have a websocket link to monitor the query.
    queries on / for all peers
      ✓ should return results from each server
    Non provisioned devices
      ✓ queries on /servers/<id> should return no results
      ✓ queries on /?server=<server> should return no results
      ✓ queries on /?server=* should return no results
      ✓ queries on / should return no results (51ms)
    queries on /servers/<id>
      ✓ should have two classes
      ✓ should have two properties: server name and ql
      ✓ should have one action.
      ✓ should have a websocket link to monitor the query.
      ✓ should return empty list if no devices are provisioned on server
    proxied queries on /servers/<id>
      ✓ should have two classes
      ✓ should have two properties: server name and ql
      ✓ should have one action.
      ✓ should have a websocket link to monitor the query.

  DeviceRegistry
    ✓ should call the callback on close
    ✓ should save a configured device to the database.
    #find
      ✓ should find a device by it's id.
      ✓ should have a callback return results in the callback of find.
      ✓ should return no results in the callback of find with a query that does not match.
      ✓ should return results with a query language query
      ✓ should return results with a Query object
      ✓ should return results with a parameterized Query object

  Remote queries
    remote query events
      ✓ should fire a remote query event on detroit1 after peers connect
      ✓ should fire remote query for both server detroit1 and chicago
      ✓ should return devices from both Z1 and Z2 after peers connects
      ✓ should return all test devices when quering .from('*')
      ✓ should return all test devices from quering .from('*') when a new peer connects (56ms)
(node:21586) Warning: Possible EventEmitter memory leak detected. 11 _streamDrain listeners added. Use emitter.setMaxListeners() to increase limit
      ✓ adding a device on the remote server should add a device to app with star query (104ms)
      ✓ should pass a remote query to peer socket through subscribe
(node:21586) Warning: Possible EventEmitter memory leak detected. 11 _streamDrain listeners added. Use emitter.setMaxListeners() to increase limit
      ✓ adding a device on the remote server should add a device to app (104ms)
    Peer Reconnects
      6) runtime should only pass the device once to app
      7) runtime should ony pass the device once to app for each peer
      8) should send back 1 result for peer after a reconnet
    Websocket Local Queries
      ✓ should send back 1 result for local device
      ✓ should send back 2 results for local device after a device is added (57ms)
      ✓ reconnecting should only have 1 result
    Websocket Proxied Queries
      ✓ should send back 1 result for local device
      ✓ should send back 2 results for local device after a device is added (56ms)
      ✓ reconnecting should only have 1 result
    Websocket Cross-Server Queries
      ✓ should send back 2 results
      ✓ should send back 3 results after a device is added

  Runtime
    Reactive
      ✓ implements the filter method.
      ✓ implements the map method.
      ✓ implements the zip method.
      ✓ implements the subscribe method.
      ✓ implements the observe method.
      ✓ calls the calls the filter method on deviceready
      ✓ calls subscribe when the observable chain is complete.
      ✓ calls map on the observable chain when an event occurs
      ✓ only calls zip when all conditions are fulfilled.
      Runtime#observe
        ✓ returns a Subscription when a subscribe function is provided
        ✓ returns an Observable when a subscribe function is not provided
        ✓ will take a single query as the first argument
        ✓ will call the observe callback when the query is fullfilled.
        ✓ will call the observe callback when all queries are fullfilled.
        ✓ will call the observe callback when all queries are fullfilled, and when events happen in any order
        ✓ will fire if a device exists in the registry and doesn't call deviceready
      Device deletion from runtime
        ✓ will delete a remote device from the runtime (113ms)
        ✓ will delete a device from the runtime (102ms)
        ✓ will delete a device from the runtime using _destroyDevice
        ✓ _destroyDevice callback will pass an error if _sendLogStreamEvent is not a function on the device prototype.
      Extended reactive syntax
        ✓ will respond the same way using the extended reactive syntax.
        ✓ take will only fire with one pair.
        ✓ will only fire take one time
        ✓ will only fire take twice.

  Scout
    ✓ runtime should export zetta.Scout
    initialization of scout
      ✓ it should implement discover prototype
      ✓ it should implement provision prototype
    #discover()
      ✓ it should pass arguments to device
      ✓ it should add a new device to the registry
    #provision()
      ✓ it should pass arguments to device
      ✓ it should initiate device with registry information
      ✓ should not return a device that has been already initialized
      ✓ device init.name() should take presedence over registry value

  Stream Topic
    ✓ will correctly parse a topic of all valid strings
    ✓ will correctly parse a topic with RegExp throughout
    ✓ will correctly parse a topic with regex and *
    ✓ will correctly parse a topic with regex and * for all paths
    ✓ will correctly parse a topic with regex and ** for paths
    ✓ will correctly parse a regex out of a topic string
    ✓ will correctly parse a query out of a topic string
    ✓ will correctly parse topics without the leading server name
    ✓ will correctly parse a topic with double star
    ✓ will correctly parse a topic hub/**/state
    ✓ will correctly parse a regex topic with a ? in it
    ✓ will correctly parse a regex topic with a ? in it and a query
    ✓ will correctly parse **/some-topic
    ✓ will correctly parse **/led/123/state
    ✓ will correctly parse **/123/state
    ✓ will correctly parse special topic _peer/connect
    ✓ will correctly parse special topic _peer/disconnect
    ✓ will correctly parse special topic _peer/*
    ✓ will correctly parse special topic _peer/**
    ✓ will correctly parse special topic query:where type="led"
    ✓ will correctly parse special topic query/where type="led"
    ✓ hash() will return the original input
    .match()
      ✓ should return true for query led/123/* on topic led/123/state
      ✓ should return false for query led/321/* on topic led/123/state
      ✓ should return false for query Detroit/led/123/* on topic led/123/state
      ✓ should return true for query led/** on topic led/123/state
      ✓ should return true for query {^Det.+$}/led/123/state on topic Detroit-123/led/123/state
      ✓ should return false for query {^Det.+$}/led/123/state on topic hub/led/123/state
      ✓ should return true for query {^Det.+$}/led/** on topic Detroit-123/led/123/stream
      ✓ should return true for query {^Det.+$}/led/123/{^stream.+$} on topic Detroit-123/led/123/stream-123
      ✓ should return true for query {^Det.+$}/**/{^stream.+$} on topic Detroit-123/led/123/stream-123
      ✓ should return true for query {^Det.+$}/** on topic Detroit-123/led/123/stream
      ✓ should return true for query */led/** on topic hub/led/123/state

  Virtual Device
    .call method
      ✓ call should work without a callback function
      9) call should work without a callback function
      10) _update should always be called with data.actions in proper format
      ✓ call should work without arguments
      11) call should work without arguments
      ✓ call should work with arguments
      12) call should work with arguments
      13) call should work with arguments, after peer reconnects
    Device log monitor stream
      14) should update virtual devices state when detroit device updates
      15) "before each" hook

  474 passing (37s)
  3 pending
  15 failing

@AdamMagaluk
Copy link
Collaborator Author

AdamMagaluk commented Dec 4, 2018

Test Report getting closer.

λ: node -v
v8.6.0
λ: npm test

> [email protected] test /Users/adammagaluk/Software/zetta/zetta
> mocha -R spec

(node:99917) [DEP0006] DeprecationWarning: child_process: options.customFds option is deprecated. Use options.stdio instead.


  Zetta Api
    ✓ updates href hosts using x-forwarded-host header (43ms)
    ✓ updates href path using x-forwarded-path header
    ✓ allow for x-forwarded-host header to be disabled
    ✓ allow for x-forwarded-path header to be disabled
    /servers/<peer id>
      ✓ should have content type application/vnd.siren+json
      ✓ should return status code 200
      ✓ should have class ["server"]
      ✓ should have proper name and id property
      ✓ should have custom properties in resp
      ✓ should have self link and log link
      ✓ should have a metadata link
      ✓ should have monitor log link formatted correctly for HTTP requests
      ✓ should have monitor log link formatted correctly for SPDY requests
      ✓ should not have an events link for SPDY requests
      ✓ should have valid entities
      ✓ should have one action
      ✓ should accept remote devices of type testdriver
      ✓ should not accept a remote device of type foo
      ✓ should accept remote devices of type testdriver, and allow them to set their own id properties
      ✓ query for device should respond with properly formated api response
    /
      ✓ should have content type application/vnd.siren+json
      ✓ should have status code 200
      ✓ body should contain class ["root"]
      ✓ body should contain links property
      ✓ links should contain rel to server
      ✓ should contain link for event stream
      ✓ should use a default server name if none has been provided
    /peer-management
      ✓ should have content type application/vnd.siren+json
      ✓ should return status code 200
      ✓ should have class ["peer-management"]
      ✓ subentities should have rel ["item"]
      ✓ should list saved peers
      ✓ should allow the querying of peers with the ql parameter
      #link
        ✓ should return status code 202
        ✓ should return a Location header
        ✓ should return Location header whose value honors forwarded host
        ✓ should return Location header whose value honors forwarded path
      #show
        ✓ should return the peer item representation
    /devices of server
      ✓ should have content type application/vnd.siren+json
      ✓ should return status code 200
      ✓ should have class ["devices"]
      ✓ should have one valid entity
      ✓ should replace url host in all device links using forwarded host
      ✓ should inject path in all device links using forwared root path
    /servers/:id/devices/:id
      ✓ should have content type application/vnd.siren+json
      ✓ class should be ["device", ":type"]
      ✓ properties should match expected
      ✓ device should have action change
      ✓ device actions should have class "transition"
      ✓ device should have self link
      ✓ device should have edit link
      ✓ device should have up link to server
      ✓ device should have monitor link for bar
      ✓ disabling a stream should remove it from the API.
      ✓ enabling a stream should show it in the API.
      ✓ device should have monitor link for bar formatted correctly for HTTP requests
      ✓ should have a monitor link for bar formatted correctly for SPDY requests
      ✓ device action should return a 400 status code on a missing request body
      ✓ device action should return a 400 status code on an invalid request body
      ✓ device action should work
      ✓ device action should support extended characters
      ✓ api should decode transition args to number for test-number
      ✓ api should decode transition args to string for test-text
      ✓ api should decode transition args to string for test-none
      ✓ api should decode transition args to object for test-date
      ✓ api should respond with 400 when argument is not expected number
      ✓ api should respond with 400 when argument is not expected Date
      ✓ device action should return 400 when not available.
      ✓ should return 500 when a error is passed in a callback of device driver
      ✓ should return custom error information when a error is passed in a callback of device driver
      ✓ should support device updates using PUT
      ✓ should support device deletes using DELETE
      ✓ remoteDestroy hook should prevent the device from being destroyed with a DELETE
      ✓ remoteDestroy hook should prevent the device from being destroyed with a DELETE if callback has an error
      ✓ remoteDestroy hook should allow the device to be destroyed when callback is called with true
      ✓ should not overwrite monitor properties using PUT
      ✓ should return a 404 when updating a non-existent device
      ✓ should return a 400 when updating with a Content-Range header
      ✓ should return a 400 when receiving invalid JSON input
      ✓ should not include reserved fields on device updates
    Proxied requests
      ✓ zetta should not crash when req to hub is pending and hub disconnects
      ✓ zetta should return 404 on non-existent peer
      ✓ zetta should return 404 on disconnected peer
      ✓ device action should support extended characters throw a proxied connection
    Server name issues
      ✓ server name with space has correct path to root of server
      ✓ server name with space has correct path to device

  Registry Compaction
    custom database
      ✓ should not have a compactor property with a custom db.
    standard medea database
      ✓ should have a compactor property without a custom db.
      ✓ should call open before compact.
      ✓ should call compact.
      ✓ should call close.

  ConsumerStream
    ✓ it should subscribe to pubsub topic
    ✓ it pass pubsub data to stream

  Driver
    ✓ should be attached to the zetta runtime
    ✓ should expose an enableStream function
    ✓ should expose a disableStream function
    Configuration
      ✓ should be configured by Scientist#configure
      ✓ should have an id automatically generated for it
      ✓ should have properties function
      ✓ properties function should return filtered property list
    Logging
      ✓ should expose a .log method
      ✓ should have log level functions
    Transitions
      ✓ should not throw when calling an invalid transition name.
      ✓ should not throw when calling a transition when destroyed.
      ✓ should not throw when calling a transition not allowed in invalid state.
      ✓ avialable transitions should not throw when in invalid state.
      ✓ should change the state from ready to changed when calling change.
      ✓ should be able to call transiton afterchange after change was called
      ✓ should not throw an error when a disallowed transition tries to happen.
      ✓ should return error in callback.
      ✓ should have transitions emitted like events.
      ✓ should publish transitions to pubsub
      ✓ should publish transitions to logs
      ✓ transitionsAvailable should return proper transitions
    Monitors
      ✓ should be able to read state property
      ✓ should be able to read monitors properties
      ✓ should be able to pass disable option to monitor
    Streams
      ✓ should stream values of foo once configured
      ✓ should be able to pass disable option to stream
      ✓ should have createReadSteam on device
      ✓ createReadStream should return values from stream
      ✓ createReadStream stream when paused shoud not recieve any updates
      ✓ should stream values of bar once configured
      ✓ should create a state stream when transitions are present
      ✓ should not create a state stream when no transitions are present
    Device.save
      ✓ save should be implemented on device
      ✓ save should update the registry with new property values
    Remote Update and Fetch Hooks
      ✓ can pass config a remoteFetch function to be called when .properties() is called
      ✓ handle remote update method, will update non reserved properties and remove old properties
      ✓ can pass config a remoteUpdate function to be called when remoteUpdates are called
    Deletion
      ✓ should have a destroy function
      ✓ should emit a destroy event when destroy is called.
      ✓ handle remote destroy method, will return true by default

  EventBroker
    ✓ it should add peer by server name
    ✓ it should pass data from local pubsub to clients
    ✓ should keep local pubsub subscription open when more than one client is active

  EventSocket
    ✓ it should initialization with topic set
    ✓ EventSocket.send should pass data/options/callback to ws send
ws error: Error: some error
    at context.<anonymous> (/Users/adammagaluk/Software/zetta/zetta/test/test_event_socket.js:48:22)
    at Test.Runnable.run (/Users/adammagaluk/Software/zetta/zetta/node_modules/mocha/lib/runnable.js:217:15)
    at Runner.runTest (/Users/adammagaluk/Software/zetta/zetta/node_modules/mocha/lib/runner.js:373:10)
    at /Users/adammagaluk/Software/zetta/zetta/node_modules/mocha/lib/runner.js:451:12
    at next (/Users/adammagaluk/Software/zetta/zetta/node_modules/mocha/lib/runner.js:298:14)
    at /Users/adammagaluk/Software/zetta/zetta/node_modules/mocha/lib/runner.js:308:7
    at next (/Users/adammagaluk/Software/zetta/zetta/node_modules/mocha/lib/runner.js:246:23)
    at Immediate.<anonymous> (/Users/adammagaluk/Software/zetta/zetta/node_modules/mocha/lib/runner.js:275:5)
    at runCallback (timers.js:781:20)
    at tryOnImmediate (timers.js:743:5)
    at processImmediate [as _immediateCallback] (timers.js:714:5)
    ✓ websocket error event should trigger close on EventSocket
    ✓ websocket close event should trigger close on EventSocket
    ✓ should init parser if passed streaming flag
    ✓ should pass filterMultiple flag to EventSocket
    ✓ should emit subscribe event when subscribe message is parsed
    ✓ should not fail when sending null object with streamEnabled=true
    ✓ should not fail when sending null object with streamEnabled=false

  Event Stream Parser
    ✓ validates subscribe messages correctly
    ✓ invalidates subscribe messages correctly
    ✓ validates unsubscribe messages correctly
    ✓ invalidates unsubscribe messages correctly
    ✓ validates unsubscribe-ack messages correctly
    ✓ invalidates unsubscribe-ack messages correctly no subscriptionId
    ✓ invalidates unsubscribe-ack messages correctly no timestamp no subscriptionId
    ✓ invalidates unsubscribe-ack messages correctly no timestamp
    ✓ validates subscribe-ack messages correctly
    ✓ validates error messages correctly
    ✓ validates event messages correctly
    ✓ should emit event for message type when parsing buffer
    ✓ should emit error for invalid message type when parsing buffer
    ✓ should emit error for invalid JSON when parsing buffer

  Peering Event Streams
    ✓ will receive a _peer/connect event when subscribed
    ✓ will receive a _peer/connect event when subscribed to **
    ✓ will receive a _peer/disconnect event when subscribed
    ✓ will receive a _peer/connect event when subscribed with wildcards
    ✓ will receive a _peer/connect and _peer/disconnect event when subscribed with wildcards

  Event Streams
    Websocket API
      ✓ for cloud, subscribing to a topic receives a subscription-ack
      ✓ for hub, subscribing to a topic receives a subscription-ack
      ✓ for cloud, sending ping request will return a pong response without data field
      ✓ for hub, sending ping request will return a pong response without data field
      ✓ for cloud, sending ping request will return a pong response with data field
      ✓ for hub, sending ping request will return a pong response with data field
      ✓ for cloud, unsubscribing to a topic receives a unsubscription-ack
      ✓ for hub, unsubscribing to a topic receives a unsubscription-ack
      ✓ for cloud, verify error message format
      ✓ for hub, verify error message format
      ✓ for cloud, specific topic subscription only receives messages with that topic (59ms)
      ✓ for hub, specific topic subscription only receives messages with that topic (55ms)
      ✓ for cloud, multiple clients specific topic subscription only receives messages with that topic (60ms)
      ✓ for hub, multiple clients specific topic subscription only receives messages with that topic (60ms)
      ✓ for cloud, multiple clients using different topic subscriptions only receive one message per event (254ms)
      ✓ for hub, multiple clients using different topic subscriptions only receive one message per event (256ms)
      ✓ for cloud, wildcard server topic subscription only receives messages with that topic (60ms)
      ✓ for hub, wildcard server topic subscription only receives messages with that topic (56ms)
      ✓ for cloud, wildcard topic and static topic subscription will receive messages for both subscriptions (62ms)
      ✓ for hub, wildcard topic and static topic subscription will receive messages for both subscriptions (59ms)
      ✓ for cloud, wildcard device id topic subscription and cloud app query both will recieve data (94ms)
      ✓ for hub, wildcard device id topic subscription and cloud app query both will recieve data (66ms)
Subscription missing for PushData: testdriver/f366ee72-2f97-4eb9-8f9b-7a2abd3c22dd/state */state testdriver/f366ee72-2f97-4eb9-8f9b-7a2abd3c22dd/state
      ✓ for cloud, wildcard device id topic subscription and hub app query both will recieve data (58ms)
      ✓ for hub, wildcard device id topic subscription and hub app query both will recieve data (58ms)
Subscription missing for PushData: testdriver/8a531548-7343-494d-b9ec-e84c36f0298b/state */state testdriver/8a531548-7343-494d-b9ec-e84c36f0298b/state
Subscription missing for PushData: testdriver/eeb488fc-c821-4685-9474-877f10bfae32/state */state testdriver/eeb488fc-c821-4685-9474-877f10bfae32/state
      ✓ wildcard server topic subscription receives messages from both hubs (64ms)
Subscription missing for PushData: testdriver/22c2d21f-de13-4685-8a09-2a24a2fd154f/state ** testdriver/22c2d21f-de13-4685-8a09-2a24a2fd154f/state
Subscription missing for PushData: testdriver/22c2d21f-de13-4685-8a09-2a24a2fd154f/logs ** testdriver/22c2d21f-de13-4685-8a09-2a24a2fd154f/logs
Subscription missing for PushData: testdriver/3d5aec3f-aad2-41a0-8a3a-eb2da82b7742/state ** testdriver/3d5aec3f-aad2-41a0-8a3a-eb2da82b7742/state
Subscription missing for PushData: testdriver/3d5aec3f-aad2-41a0-8a3a-eb2da82b7742/logs ** testdriver/3d5aec3f-aad2-41a0-8a3a-eb2da82b7742/logs
Subscription missing for PushData: testdriver/4d9c8200-48de-4d6a-9a8b-f96d959568fc/state ** testdriver/4d9c8200-48de-4d6a-9a8b-f96d959568fc/state
Subscription missing for PushData: testdriver/4d9c8200-48de-4d6a-9a8b-f96d959568fc/logs ** testdriver/4d9c8200-48de-4d6a-9a8b-f96d959568fc/logs
Subscription missing for PushData: testdriver/9645cdce-1baa-4cb7-96c8-14bb6dd6d39d/state ** testdriver/9645cdce-1baa-4cb7-96c8-14bb6dd6d39d/state
Subscription missing for PushData: testdriver/9645cdce-1baa-4cb7-96c8-14bb6dd6d39d/logs ** testdriver/9645cdce-1baa-4cb7-96c8-14bb6dd6d39d/logs
      ✓ wildcard topic ** will subscribe to all topics for both hubs (268ms)
      ✓ wildcard topic ** will subscribe to all topics for single hub (56ms)
Subscription missing for PushData: testdriver/991db6a6-1f16-469f-9dd8-afcbb55653de/state */state testdriver/991db6a6-1f16-469f-9dd8-afcbb55653de/state
Subscription missing for PushData: testdriver/91e36bc2-9571-4350-9251-8f3742fd69e5/state */state testdriver/91e36bc2-9571-4350-9251-8f3742fd69e5/state
      ✓ for cloud, wildcard topic for single peer receives all messages for all topics (57ms)
      ✓ for hub, wildcard topic for single peer receives all messages for all topics (53ms)
Subscription missing for PushData: testdriver/c36f2c8f-5bf4-443d-b3b4-18680d79b81b/state ** testdriver/c36f2c8f-5bf4-443d-b3b4-18680d79b81b/state
Subscription missing for PushData: testdriver/c36f2c8f-5bf4-443d-b3b4-18680d79b81b/logs ** testdriver/c36f2c8f-5bf4-443d-b3b4-18680d79b81b/logs
Subscription missing for PushData: testdriver/225cda7c-7c65-46cd-8cdd-d93ff1678cb2/state ** testdriver/225cda7c-7c65-46cd-8cdd-d93ff1678cb2/state
Subscription missing for PushData: testdriver/225cda7c-7c65-46cd-8cdd-d93ff1678cb2/logs ** testdriver/225cda7c-7c65-46cd-8cdd-d93ff1678cb2/logs
      ✓ for cloud, wildcard topic for device id and stream types receives all messages for all topics (64ms)
      ✓ for hub, wildcard topic for device id and stream types receives all messages for all topics (56ms)
      ✓ for cloud, **/led/<device_id>/state will match valid topic (59ms)
      ✓ for hub, **/led/<device_id>/state will match valid topic (57ms)
      ✓ for cloud, **/<device_id>/state will match valid topic from device (54ms)
      ✓ for hub, **/<device_id>/state will match valid topic from device (56ms)
      ✓ for cloud, **/state will match valid topic from device (60ms)
      ✓ for hub, **/state will match valid topic from device (58ms)
Subscription missing for PushData: testdriver/1e15ee4a-2a15-4243-9ad3-71c4066504de/logs */logs testdriver/1e15ee4a-2a15-4243-9ad3-71c4066504de/logs
      ✓ for cloud, subscribing to logs topic on device will get properly formated response (58ms)
      ✓ for hub, subscribing to logs topic on device will get properly formated response (57ms)
      ✓ for cloud, topic that doesnt exist still opens stream
      ✓ for hub, topic that doesnt exist still opens stream
Subscription missing for PushData: _peer/connect ** _peer/connect
      ✓ subscription cloud will get _peer/connect events from hub
      ✓ for cloud, subscription to non existent hub does not return data for that subscriptionId (61ms)
      ✓ for hub, subscription to non existent hub does not return data for that subscriptionId (56ms)
      ✓ for cloud, wildcard and specific topic will each publish a message on a subscription (72ms)
      ✓ for hub, wildcard and specific topic will each publish a message on a subscription (60ms)
      ✓ for cloud, adding limit to subscription should limit number of messages received (275ms)
      ✓ for hub, adding limit to subscription should limit number of messages received (266ms)
      ✓ for cloud, when limit is reached a unsubscribe-ack should be received (71ms)
      ✓ for hub, when limit is reached a unsubscribe-ack should be received (57ms)
      ✓ for cloud, when limit is reached with a query selector a unsubscribe-ack should be received (71ms)
      ✓ for hub, when limit is reached with a query selector a unsubscribe-ack should be received (59ms)
      ✓ for cloud, query field selector should only return properties in selection (69ms)
      ✓ for hub, query field selector should only return properties in selection (56ms)
      ✓ for cloud, query field selector * should all properties in selection (58ms)
      ✓ for hub, query field selector * should all properties in selection (54ms)
      ✓ for cloud, query field selector should return only selected properties (57ms)
      ✓ for hub, query field selector should return only selected properties (53ms)
      ✓ for cloud, subscribing to all ** and then unsubscribing followed by a peer connecting wont crash zetta (509ms)
      ✓ for hub, subscribing to all ** and then unsubscribing followed by a peer connecting wont crash zetta (413ms)
      ✓ for cloud, Passing filterMultiple options to ws only one data event will be sent (57ms)
      ✓ for hub, Passing filterMultiple options to ws only one data event will be sent (58ms)
      ✓ for cloud, Passing filterMultiple options to ws will apply limits for both topics (61ms)
      ✓ for hub, Passing filterMultiple options to ws will apply limits for both topics (54ms)
      ✓ for cloud, Passing filterMultiple options to ws will have no effect on topics with caql query (62ms)
      ✓ for hub, Passing filterMultiple options to ws will have no effect on topics with caql query (54ms)
      ✓ for cloud, subscribing to a query with hub for hub will return all devices
      ✓ for hub, subscribing to a query with hub for hub will return all devices
      ✓ for cloud, subscribing to a query with * for hub will return all devices
      ✓ for hub, subscribing to a query with * for hub will return all devices
      ✓ for cloud, when data is 0 value it should be formatted correctly (56ms)
      ✓ for hub, when data is 0 value it should be formatted correctly (54ms)
      Protocol Errors
        ✓ for cloud, invalid stream topic "*" should result in a 400 error
        ✓ for hub, invalid stream topic "*" should result in a 400 error
        ✓ for cloud, invalid stream topic "hub" should result in a 400 error
        ✓ for hub, invalid stream topic "hub" should result in a 400 error
        ✓ for cloud, invalid stream topic "{hub.+}" should result in a 400 error
        ✓ for hub, invalid stream topic "{hub.+}" should result in a 400 error
        ✓ for cloud, invalid stream topic "*/" should result in a 400 error
        ✓ for hub, invalid stream topic "*/" should result in a 400 error
        ✓ for cloud, invalid stream topic "**/" should result in a 400 error
        ✓ for hub, invalid stream topic "**/" should result in a 400 error
        ✓ for cloud, invalid stream topic "hub/" should result in a 400 error
        ✓ for hub, invalid stream topic "hub/" should result in a 400 error
        ✓ for cloud, invalid stream topic "{hub.+}/" should result in a 400 error
        ✓ for hub, invalid stream topic "{hub.+}/" should result in a 400 error
        ✓ for cloud, invalid stream query should result in a 400 error
        ✓ for hub, invalid stream query should result in a 400 error
        ✓ for cloud, invalid subscribe should result in a 400 error
        ✓ for hub, invalid subscribe should result in a 400 error
        ✓ for cloud, unsubscribing from an invalid subscriptionId should result in a 405 error
        ✓ for hub, unsubscribing from an invalid subscriptionId should result in a 405 error
        ✓ for cloud, invalid type should result in a 405 error
        ✓ for hub, invalid type should result in a 405 error
        ✓ for cloud, unsubscribing from a missing subscriptionId should result in a 400 error
        ✓ for hub, unsubscribing from a missing subscriptionId should result in a 400 error
        ✓ for cloud, on invalid message should result in a 400 error
        ✓ for hub, on invalid message should result in a 400 error

  Event Websocket
    Basic Connection
      ✓ http resource should exist with statusCode 200
      ✓ websocket should connect
      ✓ will return a 404 on non ws urls
      - will return a 404 on non ws urls for /events123123
    Embedding a websocket server
      ✓ can connect to the custom server
      ✓ will fire the connection event on the server
      ✓ can send data down the server websocket
      ✓ can send data up the server websocket
      - will return a 404 on non ws urls
    Receive json messages
      ✓ websocket should recv only one set of messages when reconnecting
      ✓ websocket should connect and recv data in json form
      ✓ websocket should connect and recv device log events from property API updates
      ✓ websocket should connect and recv device log events
      ✓ websocket should recv connect and disconnect message for /peer-management
    Receive binary messages
      ✓ websocket should connect and recv data in binary form

  Event Websocket Proxied Through Peer
    Basic Connection
      ✓ http resource should exist with statusCode 200
      ✓ websocket should connect
    Receive json messages
      ✓ websocket should connect and recv data in json form (110ms)
      ✓ websocket should recv only one set of messages when reconnecting (622ms)
      ✓ websocket should connect and recv device log events (111ms)
    Receive binary messages
      ✓ websocket should connect and recv data in binary form (110ms)

  Metadata API
    ✓ should contain a metadata class
    ✓ should contain a self link
    ✓ should contain a server link
    ✓ should contain a monitor link
    Type Sub-entity
      ✓ should contain a type class
      ✓ should contain properties
      ✓ should contain streams
      ✓ should contain transitions
      ✓ should contain a self link
    Type Sub-resource
      ✓ should contain a type class
      ✓ should contain properties
      ✓ should contain streams
      ✓ should contain transitions
      ✓ should contain a self link
      ✓ should contain a collection link
      ✓ should contain an instances link

  Peer Client
    ✓ should emit error when underlying ws does
    ✓ should emit closed when underlying ws does
    url parsing
      ✓ should calculate the proper url with a trailing slash
      ✓ should calculate the proper url without a trailing slash

  Peer Connection Logic
    #link
      ✓ should work before .listen is ran
      ✓ should work after .listen is ran
      ✓ should wire up request extensions
      ✓ should wire up response extensions
    Handle spdy agent errors
      - should catch error event
    Peer_socket error events
      ✓ http-server should handle multiple error events
      ✓ http-server should handle multiple end events
    Handle timings with ws connects vs actual peer connects
      ✓ peer connects should be the same peer object on the cloud
      ✓ peer connects should be the same peer object on the cloud with reconnect (587ms)
      1) peer connects should be the same peer object on the cloud with reconnect with timing issue
      2) "after each" hook

  309 passing (14s)
  3 pending
  2 failing

  1) Peer Connection Logic Handle timings with ws connects vs actual peer connects peer connects should be the same peer object on the cloud with reconnect with timing issue:
     Uncaught TypeError: Cannot read property 'end' of null
      at module.exports.PeerSocket.close (/Users/adammagaluk/Software/zetta/zetta/lib/peer_socket.js:88:18)
      at /Users/adammagaluk/Software/zetta/zetta/lib/peer_socket.js:122:14
      at ClientRequest.<anonymous> (/Users/adammagaluk/Software/zetta/zetta/lib/peer_socket.js:423:5)
      at emitOne (events.js:115:13)
      at ClientRequest.emit (events.js:210:7)
      at Socket.socketErrorListener (_http_client.js:401:9)
      at emitOne (events.js:115:13)
      at Socket.emit (events.js:210:7)
      at Stream.onStreamError (/Users/adammagaluk/Software/zetta/node-spdy/lib/spdy/handle.js:110:18)
      at emitOne (events.js:115:13)
      at Stream.emit (events.js:210:7)
      at /Users/adammagaluk/Software/zetta/spdy-transport/lib/spdy-transport/connection.js:757:12
      at Array.forEach (<anonymous>)
      at Connection.destroyStreams (/Users/adammagaluk/Software/zetta/spdy-transport/lib/spdy-transport/connection.js:753:33)
      at Socket.onclose (/Users/adammagaluk/Software/zetta/spdy-transport/lib/spdy-transport/connection.js:183:10)
      at Object.onceWrapper (events.js:316:30)
      at emitOne (events.js:115:13)
      at Socket.emit (events.js:210:7)
      at TCP._handle.close [as _onclose] (net.js:547:12)

  2) Peer Connection Logic Handle timings with ws connects vs actual peer connects "after each" hook:
     Uncaught TypeError: Cannot read property 'end' of null
      at module.exports.PeerSocket.close (/Users/adammagaluk/Software/zetta/zetta/lib/peer_socket.js:88:18)
      at /Users/adammagaluk/Software/zetta/zetta/lib/peer_socket.js:122:14
      at ClientRequest.<anonymous> (/Users/adammagaluk/Software/zetta/zetta/lib/peer_socket.js:423:5)
      at emitOne (events.js:115:13)
      at ClientRequest.emit (events.js:210:7)
      at Socket.socketCloseListener (_http_client.js:377:9)
      at emitOne (events.js:115:13)
      at Socket.emit (events.js:210:7)
      at _handle.close (net.js:547:12)
      at _combinedTickCallback (internal/process/next_tick.js:131:7)
      at process._tickDomainCallback (internal/process/next_tick.js:218:9)



npm ERR! Test failed.  See above for more details.

Updates to the WS cause it to return a 400 instead of a 404 when
the base path does not match.
…ribe's cb

to fire a second time. Wrap cb in a once pattern.

PeerSocket guard against this.ws not being initialized when closing the connection
Our tests are scheduling async operations and calling done. We
need to clean this up but with the old version of mocha it was
exiting the test suite after all tests were done. This enforces
the old behavior.
@AdamMagaluk
Copy link
Collaborator Author

Closing to create a new PR with cleaner history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants